var fs = require("fs");
var buf = new Buffer(1024);

console.log("准备打开文件！");

var start = new Date('1900-01-01');
console.log('start', start.getFullYear());
console.log('start', start.getMonth() + 1);
console.log('start', start.getDay());
console.log('start', start.getTime());

function getNextDay(d) {
    d = +d + 1000 * 60 * 60 * 24;
    d = new Date(d);
    return d;
    //格式化
    // return d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();

}

function getFormatDate(date) {
    var year = date.getFullYear();
    var month = date.getMonth() + 1;
    var strDate = date.getDate();
    if (month >= 1 && month <= 9) {
        month = "0" + month;
    }
    if (strDate >= 0 && strDate <= 9) {
        strDate = "0" + strDate;
    }
    return '' + year + month + strDate;
}
var zi = [];
var data = '';
for (; start.getFullYear() < 2018; start = getNextDay(start)) {
    zi.push(getFormatDate(start));
}
for (var i = 0; i < zi.length; i++) {
    data = data + zi[i] + '\n';
}
var filename = "birthday.txt";
var callback = function () {
    console.log("callback exe...");
};

fs.writeFile(filename, data, callback);
